package com.zhny.spraygun.rtu.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.modbus.ModemServer;
import com.zhny.aiot.plugin.modbus.device.ModemConfig;
import com.zhny.aiot.plugin.modbus.device.ModemDeviceFactory;
import com.zhny.aiot.plugin.modbus.handler.model.ModemRequestMessage;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.spraygun.rtu.plugin.model.SpraygunRTUStoreEntry;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.ArrayList;
import java.util.List;

public class SpraygunRTUPlugin extends Plugin {
    public SpraygunRTUPlugin(PluginWrapper wrapper) {
        super(wrapper);
    }

    @Extension
    public static class RollFilmFactory extends ModemDeviceFactory<SpraygunRTUStoreEntry> {

        public ModemRequestMessage getRequestMessage(ModemConfig modemConfig) {
            return null;
        }

        @Override
        public List<CommandEntry> supportCommandClasses(){
            List<CommandEntry> commands = new ArrayList<> ();
            commands.add(CommandEntry.valueOf("sprayGunOpen", "喷枪打开", "无参数",null));
            commands.add(CommandEntry.valueOf("sprayGunClose", "喷枪关闭", "无参数",null));
            commands.add(CommandEntry.valueOf("sprayGunQuery", "喷枪查询", "无参数",null));
            return commands;
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new SpraygunRTUDevice (ModemServer.getInstance ().getEngine () ,this,iCenterFacilities,entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return SpraygunRTUStoreEntry.class;
        }

        public String getId() {
            return "zhny-spraygun-rtu-plugin";
        }

        public String getName() {
            return "智慧喷枪RTU插件";
        }

        public FactoryType getType() {
            return FactoryType.OpenCloseController;
        }
    }
}
